Skip to content

fix: derive activity counts from paged nodes instead of search [CM-1220]#4192

Merged
mbani01 merged 1 commit into
mainfrom
fix/missing_activity_count
Jun 10, 2026
Merged

fix: derive activity counts from paged nodes instead of search [CM-1220]#4192
mbani01 merged 1 commit into
mainfrom
fix/missing_activity_count

Conversation

@mbani01

@mbani01 mbani01 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors how pull request (PR) and issue activity metrics are computed and retrieved in the fetchActivitySnapshot.ts worker. The main change is moving from GraphQL search-based aggregate queries to calculating metrics directly from the fetched PR and issue nodes, making the code more reliable and easier to maintain. It also introduces some small improvements and simplifications to the type definitions and query parameters.

Key changes include:

Metrics Calculation Refactor

  • Replaces GraphQL search queries for PR and issue counts with direct calculations on the fetched PR and issue nodes, improving accuracy and reducing complexity. For example, PRs opened, merged, and closed-unmerged in the last 12 months are now counted from the node data rather than relying on search queries. [1] [2] [3] [4] [5]

  • Calculates issues opened in the last 6 months by filtering the fetched issue nodes by createdAt, instead of using a separate search query.

GraphQL Query and Type Updates

  • Removes unused search query variables and fields from the GraphQL summary query, simplifying the query structure. [1] [2]

  • Adds closedAt to the PR node interface and GraphQL query, enabling accurate computation of closed-unmerged PRs. [1] [2]

  • Adds a direct query for the current number of open issues (openIssues) on the repository. [1] [2]

Code and Type Simplifications

  • Removes the toDateString helper and unused date string fields from the date window builder, as they are no longer needed for search queries. [1] [2]

  • Cleans up unused type definitions related to the old search-based approach.

These changes make the codebase more maintainable and ensure that activity metrics are calculated consistently from the same set of fetched data.


Note

Medium Risk
Published enrichment metrics may shift if search totals previously disagreed with the paged 12m window or if paging stops early on very active repos.

Overview
Activity snapshot metrics in fetchActivitySnapshot no longer use GitHub GraphQL search issueCount queries. PR and issue volume fields (opened/merged/closed in the 12m window, 6m issue splits) are derived from the same paged PR/issue nodes already fetched for median calculations.

The summary query is trimmed to commit history plus repository.openIssues for issues open now. PR paging now requests closedAt (and PrNode is updated) so closed-unmerged PRs can be counted as closedAt && !mergedAt. Date-window helpers drop search-only date strings and expose since6m for filtering 6-month issue opens on the node list.

Reviewed by Cursor Bugbot for commit 56a718a. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
@mbani01 mbani01 self-assigned this Jun 10, 2026
Copilot AI review requested due to automatic review settings June 10, 2026 15:08
@mbani01 mbani01 changed the title fix: derive activity counts from paged nodes instead of search fix: derive activity counts from paged nodes instead of search [CM-1220] Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the packages_worker GitHub repo enricher’s activity snapshot logic to compute PR/issue volume metrics directly from the paged PR/issue nodes already fetched for median calculations, removing reliance on GitHub GraphQL search(issueCount) aggregates. It also trims the summary GraphQL query and updates types/queries to support the new calculations (notably adding closedAt on PR nodes and fetching repository.issues(states: OPEN).totalCount for “open now”).

Changes:

  • Remove GraphQL search-based aggregate counts from the summary query and derive 12-month / 6-month activity counts from paged PR/issue nodes.
  • Add closedAt to PR paging and PrNode typing to enable “closed-unmerged” PR counting.
  • Add a direct openIssues total count query on the repository and simplify date window helpers accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
services/apps/packages_worker/src/enricher/fetchActivitySnapshot.ts Refactors metrics calculation away from search aggregates; trims summary query; adds closedAt to PR paging; uses repo openIssues totalCount.
services/apps/packages_worker/src/enricher/computeMedians.ts Extends PrNode shape to include closedAt to match the updated GraphQL paging query.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +340 to +342
const issuesOpenedLast6m = issueResult.nodes.filter(
(n) => new Date(n.createdAt) >= since6m,
).length
@mbani01
mbani01 merged commit 53e5262 into main Jun 10, 2026
20 of 21 checks passed
@mbani01
mbani01 deleted the fix/missing_activity_count branch June 10, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants